#ifndef BE_TCP_SOCKET_H_INCLUDED
#define BE_TCP_SOCKET_H_INCLUDED

#include <string>
#include <SDL/SDL_net.h>

#include <boost/shared_ptr.hpp>

class BeTcpSocket
{
public:
	BeTcpSocket(TCPsocket socket);
	BeTcpSocket();
	~BeTcpSocket()
	{
		close();
	}
	boost::shared_ptr<BeTcpSocket> accept();
	void open(const char* const hostIp, const Uint16 port);
	void open(IPaddress& ipAddress);
	void close();
	size_t send(const void* const data, const size_t size);
	size_t recieve(void* const data, const size_t size);
	bool isReady();
	const IPaddress* getIpAddress() const
	{
		return SDLNet_TCP_GetPeerAddress(m_socket);
	}
private:
	TCPsocket m_socket;
	IPaddress m_ipAddress;
	SDLNet_SocketSet m_socketSet;
};

#endif
